<?php
 $includePath = "../";
 $includes = array("physical-html.js", "thirdparty/cacheTweets.js");
 $tests = array("simpleHarmonicMotionTest", "bouncingParticleTest", "particleFactoryTest", "twitterLetterParticlesTest");
?>
<?php foreach ($includes as $include){ ?>
<script type="text/javascript">
var phFileNamePrefix = "..";
</script>
<script type="text/javascript" src="<?php echo $includePath . $include; ?>">
<?php } ?>
</script>
<button id="runUnitTest">Start this test</button>
<span id="testResult" style="background-color: white;"></span>
<script type="text/javascript">
  var tests = new Array();
  <?php foreach ($tests as $test){ echo "tests.push('$test'); "; }?>
  var runUnitTest = document.getElementById('runUnitTest');
  runUnitTest.addEventListener('click',
    function ()
    {
      var currentTest = mySlideShow.current - 1;
      var testName = window[tests[currentTest]];
      if(typeof testName == 'function') {
        document.getElementById("testResult").style.color="blue";
        document.getElementById("testResult").innerHTML="Running " + tests[currentTest];
        try{
          var result = testName();
          if (result == true){
            document.getElementById("testResult").style.color="green";
            document.getElementById("testResult").innerHTML= tests[currentTest] + " result: Success!";
          }
        }
        catch(e){
            document.getElementById("testResult").style.color="red";
            document.getElementById("testResult").innerHTML= tests[currentTest] + " result: Fail: " + e.message;
        }
      }
    }
  , true);
</script>
<?php foreach ($tests as $test){ ?>
  <div class="slide">
  <header><?php echo $test;?></header>
  <section>
  <?php include($test.".php");?>
  </section>
  </div>
<?php } ?>

  <div class="slide">
  <header>To do list</header>
  <section>
  <?php include("todo.php"); ?>
  </section>
  </div>
